<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box" style="text-align:center">
      购买成功  5 秒之后，跳转到首页
    </div>
</body>
<script src="js/jquery.js"></script>
<script>
    var div = document.getElementById("box");
    var num = 5;

    var timer = null;
    timer = setInterval(() => {
        num --;
        div.innerHTML = "购买成功"+num +"秒之后跳转首页";

        if (num == 0) {
            clearInterval(timer);
            location.href = "../index.html";
        }
    }, 1000 );
</script>

</html>